﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Agency_changeproduct : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {


            showGridView();
        }
    }


    /// <summary>
    /// 将数据绑定到datalist
    /// </summary>
    public void showGridView()
    {
        string strConditions;
        strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "product";                                               //要查询的表明
        dbPage.Key = "productid";                                               //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "ProductCode,productid,ProductName,Medicinemodel,Outlookc,Unit";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 20;                                                    //没有显示记录条数   
        dbPage.OrderBy = "productid";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        dtlProduct.DataSource = dr;
        dtlProduct.DataBind();
        dr.Close();
        dbPage.Db.Close();
        db.Close();
        dr = null;
        db = null;
        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键

    }
    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
    public string fctConditions()
    {
        string strtemp, ProductName, Medicinemodel, Outlookc, Unit, ProductCode, Productid;

        ProductName = this.productname.Text.Trim();
        Medicinemodel = this.medicinemodel.Text.Trim();
        Outlookc = this.OutlookC.Text.Trim();
        Unit = this.Unit.Text.Trim();
        Productid = this.Productid.Text.Trim();
        ProductCode = this.ProductCode.Text.Trim();
        strtemp = "";
        if (ProductName!= "")
        {
            strtemp = strtemp + " ProductName like '%" + ProductName + "%' and";
        }
        if (Medicinemodel!= "")
        {
            strtemp = strtemp + " Medicinemodel like '%" + Medicinemodel + "%' and";
        }
        if (Outlookc!= "")
        {
            strtemp = strtemp + " Outlookc like '%" + Outlookc + "%' and";
        }
        if (Unit!= "")
        {
            strtemp = strtemp + " Unit like '%" + Unit + "%' and";
        }
        if (Productid != "")
        {
            strtemp = strtemp + " Productid like '%" + Productid + "%' and";
        }
        if (ProductCode != "")
        {
            strtemp = strtemp + " ProductCode like '%" + ProductCode + "%' and";
        }  
        if (strtemp != "")
        {
            strtemp = "  " + strtemp.Substring(0, strtemp.Length - 3);
        }
        return strtemp;

    }

}
